package it.asvp.asvp_portal.data.entity.art;

import it.asvp.asvp_portal.asvp_util.enumerative.ArtType;
import it.asvp.asvp_portal.data.entity.domain.BaseEntity;
import it.asvp.asvp_portal.data.entity.member.Member;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@SuppressWarnings("serial")
@Entity
@Table(name = "art")
public class Art extends BaseEntity {

  @ManyToOne(fetch = FetchType.EAGER)
  @JoinColumn(name = "id_member", nullable = false)
  private Member          member;

  @Column(name = "art_type", nullable = false, length = 50)
  @Enumerated(EnumType.STRING)
  private ArtType         artType;

  @Column(name = "title", nullable = false, length = 100)
  private String          title;

  @Column(name = "description", nullable = false, length = 500)
  private String          description;

  @OneToMany(fetch = FetchType.LAZY, mappedBy = "art")
  @Cascade({ CascadeType.ALL })
  private Set<ArtPicture> artPictures = new HashSet<ArtPicture>(0);

  public Art() {
  }

  public Art(Member member, ArtType artType, String title, String description, Date createdOn, Date lastUpdate, Set<ArtPicture> artPictures) {
    this.member = member;
    this.artType = artType;
    this.title = title;
    this.description = description;
    this.createdOn = createdOn;
    this.lastUpdate = lastUpdate;
    this.artPictures = artPictures;
  }

  public Member getMember() {
    return this.member;
  }

  public void setMember(Member member) {
    this.member = member;
  }

  public ArtType getArtType() {
    return this.artType;
  }

  public void setArtType(ArtType artType) {
    this.artType = artType;
  }

  public String getTitle() {
    return this.title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public String getDescription() {
    return this.description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public Set<ArtPicture> getArtPictures() {
    return this.artPictures;
  }

  public void setArtPictures(Set<ArtPicture> artPictures) {
    this.artPictures = artPictures;
  }

}
